package com.hmdp.controller;


import com.hmdp.dto.Result;
import com.hmdp.service.IFollowService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 虎哥
 * @since 2021-12-22
 */
@RestController
@RequestMapping("/follow")
public class FollowController {
    @Resource
    private IFollowService followService;
    @GetMapping("/or/not/{id}")
    public Result follow(@PathVariable("id" )Long followUserId){
//      进入页面返回是否关注
        return followService.isFollow(followUserId);
    }

    @PutMapping("/{id}/{isFollow}")
    public Result follow(@PathVariable("id" )Long followUserId,@PathVariable("isFollow") Boolean isFollow){
//      关注或者取关
        return followService.followOrNot(followUserId,isFollow);
    }
//    获取共同关注
    @GetMapping("/common/{id}")
    public Result followCommons(@PathVariable("id") Long otherUserId){
        return  followService.followCommons(otherUserId);

    }
}
